import 'rc_status_define.dart';
import 'message_content.dart';
import 'dart:convert' show json;

class ImageMessage extends MessageContent {
  static const String objectName = "RC:ImgMsg";

  String localPath;
  String extra;
  String content;
  String imageUri;
  Map user;

  @override
  void decode(String jsonStr) {
    Map map = json.decode(jsonStr.toString());
    this.localPath = map["localPath"];
    this.content = map["content"];
    this.imageUri = map["imageUri"];
    this.extra = map["extra"];
    this.user = map["user"];
  }

  @override
  String encode() {
    Map map = {
      "localPath": this.localPath,
      "extra": this.extra,
      "imageUri": this.imageUri,
      "content": this.content,
      "user": this.user,
    };
    return json.encode(map);
  }

  @override
  String conversationDigest() {
    return "图片";
  }

  @override
  String getObjectName() {
    return objectName;
  }

  static int persistentFlag() {
    return RCMessagePersistentFlag.IsPersisted |
        RCMessagePersistentFlag.IsCounted;
  }
}
